import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: JSON.parse(localStorage.getItem('userInfo')) || {},
    newsList: JSON.parse(localStorage.getItem('newslist')) || [],
    chatList: [],
    linkList: JSON.parse(localStorage.getItem('linklist')) || [],
    heUser: {},
    lookList: [],
    newList: []
  },
  mutations: {
    setNewsList(state,value) {
      localStorage.setItem('newslist',JSON.stringify(value))
      state.newsList = value
    },
    setUserInfo(state,value) {
      localStorage.setItem('userInfo',JSON.stringify(value))
      state.userInfo = value
    },
    setChatList(state,value) {
      state.chatList = value
    },
    pushChatList(state,value) {
      state.chatList.push(value)
    },
    setLinkList(state,value) {
      localStorage.setItem('linklist',JSON.stringify(value))
      state.linkList = value
    },
    setHeUser(state,value) {
      state.heUser = value
    },
    setLookList(state,value) {
      state.lookList = value
    },
    setNewList(state,value) {
      state.newList = value
    }
  },
  actions: {
  },
  modules: {
  }
})
